package org.wx.io.netty.rpc.protocol;

import lombok.Data;

import java.io.Serializable;
import java.util.UUID;

/**
 * @description: 传输的协议头
 * @author: wangxun
 * @createDate: 2021/2/23
 * @version: 1.0
 */
@Data
public class MyHeader implements Serializable {
    /*
    命令协议参数
     */
    int flag;
    /*
    本次请求的ID
     */
    long requestId;
    /*
    数据长度
     */
    int dataLen;

    public static MyHeader createHeader(byte[] data){
        MyHeader myHeader = new MyHeader();
        myHeader.setFlag(0X14141414);
        myHeader.setRequestId(Math.abs(UUID.randomUUID().getLeastSignificantBits()));
        myHeader.setDataLen(data.length);
        return myHeader;
    }

    public static MyHeader createHeader(){
        MyHeader myHeader = new MyHeader();
        myHeader.setFlag(0X14141414);
        myHeader.setRequestId(Math.abs(UUID.randomUUID().getLeastSignificantBits()));

        return myHeader;
    }


}
